const db = require('../db/index')
const bcrypt = require('bcryptjs')
exports.login=(req,res)=>{
    res.send('login ok')
}
exports.regUser=(req,res)=>{
    const userinfo = req.body
    if(!userinfo.username || !userinfo.password){
        return res.send({
            status:1,
            message:'用户不合法'
        })
    }
    const sqlStr='select * from ev_users where username=?'
    db.query(sqlStr,userinfo.username,(err,results)=>{
        if(err){
            // return res.send({status:1,message:err.message})
            return res.cc(err)
        }
        if(results.length>0){
            return res.send({status:1,message:'用户名被占用'})
        }
    })
    console.log(userinfo)
    userinfo.password=bcrypt.hashSync(userinfo.password,10)
    console.log(userinfo)
    res.send('regUser ok')
}